class Base:
    x = 1

obj = Base()

print(obj.x)        #1
obj.y = 123
print(obj.y)        #123
obj.x = 123
print(obj.x)        #123
print(Base.x)       #1


class Parent:
    x = 1

class Child1(Parent):
    pass

class Child2(Parent):
    pass

print(Parent.x, Child1.x, Child2.x)   #1,1,1
Child2.x = 2
print(Parent.x, Child1.x, Child2.x)   #1,1,2
Child1.x = 3
print(Parent.x, Child1.x, Child2.x)   #1,3,2

class Foo(object):
    n1 = '武沛齐'
    n2 = '金老板'
    def __init__(self):
        self.n1 = '女神'

obj = Foo()
print(obj.n1)   #女神
print(obj.n2)   #金老板

class Foo(object):
    n1 = '武沛齐'
    def __init__(self,name):
        self.n2 = name
obj = Foo('太白')
print(obj.n1)   #武沛齐
print(obj.n2)   #太白
print(Foo.n1)   #武沛齐
# print(Foo.n2)   #AttributeError


class Foo(object):
    a1 = 1
    __a2 = 2
    def __init__(self, num):
        self.num = num
        self.__salary = 1000

    def show_data(self):
        print(self.num + self.a1)

obj = Foo(666)

print(obj.num)   #666
print(obj.a1)    #1
# print(obj.__salary)
# print(obj.__a2)
print(Foo.a1)   #1
# print(Foo.__a2) #报错


class Foo(object):

    def f1(self):
        return 999

    def f2(self):
        v = self.f1()
        print('f2')
        return v

    def f3(self):
        print('f3')
        return self.f2()

    def run(self):
        result = self.f3()
        print(result)

obj = Foo()
v1 = obj.run()
print(v1)

# f3，f2，999 None